package com.atguigu.controller;

import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ai")
public class SpringAiTextController {
    @Autowired
    ChatModel chatModel;
    @RequestMapping("/text")
    public String text( String text){
        return chatModel.call(text);
    }
    @GetMapping("steam")
    public Flux<String> steam(String text){
        Flux<String> stream = chatModel.stream(text);
        return stream;
    }
}
